from django.db import models
from cmdb.models import Hosts

# Create your models here.
class Item(models.Model): # 项目 项目名称-官网前台
    itemname = models.CharField(max_length=100,unique=True)
    host = models.ManyToManyField(Hosts)

class Server(models.Model): # 软件服务 apache 2.2.5
    servername = models.CharField(max_length=100)
    version = models.CharField(max_length=100)
    class meta:
        unique_together = (('servername','version'),)

class Programs(models.Model): # 运行程序 apacheZifsc
    programname = models.CharField(max_length=100)
    host = models.ForeignKey(Hosts)
    itemname = models.ForeignKey(Item)
    servername = models.ForeignKey(Server)

class ProgramDetail(models.Model): # program: apacheZifsc key: port value: 8860
    program = models.ForeignKey(Programs)
    key = models.CharField(max_length=100)
    value = models.CharField(max_length=100)

    class meta:
        unique_together = (('programname','key','value'),)
